package com.hllxd.hism.star.basic.service.config.influxdb;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * author: xiyong.lxy
 * date: 2018-11-28 9:12
 */
@Configuration
public class InfluxDBConfiguration {

    private static final Logger LOGGER = LoggerFactory.getLogger(InfluxDBConfiguration.class);
    @Value("${influx.user}")
    private String username = "dq";//用户名
    @Value("${influx.pswd}")
    private String password = "dq123";//密码
    @Value("${influx.host}")
    private String openurl = "http://127.0.0.1:8086";//InfluxDB连接地址
    @Value("${influx.db_name}")
    private String database = "bcp_time_series";//数据库

    @Bean
    public InfluxDBConnect getInfluxDBConnect(){
        InfluxDBConnect influxDB = new InfluxDBConnect(username, password, openurl, database);
        influxDB.influxDbBuild();
        //influxDB.createRetentionPolicy();
        LOGGER.info("influx db connect success. {}, {}, {}, {}", username, password, openurl, database);
        return influxDB;
    }
}
